home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / vbgi.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  1KB  |  46 lines

  1. // Virtual BGI functions
  2.  
  3. #include <stdlib.h>
  4. #include <gbuf.h>
  5.  
  6. unsigned char s_fill[8];
  7.  
  8. inline int pixel_color(loc p, int attr, int bak)          // put pixel with
  9.     {                                                     // attr or bak
  10.     div_t sx, sy;                                         // color, using fill
  11.     sx = div(p.X, 8);
  12.     sy = div(p.Y, 8);
  13.     int col = s_fill[sy.rem] & (1 << sx.rem) ? attr : bak;
  14.     return col;
  15.     }
  16.  
  17.  
  18. void bar(GrafBuffer* buf, rect coord)
  19.     {
  20.     int start_bound = coord.origin.Y / buf->bound_size.Y;
  21.     int end_bound = coord.corner.Y / buf->bound_size.Y + 1;
  22.     loc dis(1, 4);
  23.     getfillpattern(s_fill);
  24.     int attr = getcolor();
  25.     struct fillsettingstype fillinfo;
  26.     getfillsettings(&fillinfo);
  27.     int bak = fillinfo.color;
  28.  
  29.     for(int i = start_bound; i < end_bound; i++)
  30.     {
  31.     int shift = buf->bound_size.Y * i;
  32.     buf->get_bound(i);
  33.     int start = 0, end = buf->bound_size.Y;
  34.     if(i == start_bound)
  35.         start = coord.origin.Y - i * buf->bound_size.Y;
  36.     if(i == end_bound - 1)
  37.         end = coord.corner.Y - i * buf->bound_size.Y;
  38.     for(int y = start; y < end; y++)
  39.         for(int x = coord.origin.X; x < coord.corner.X; x++)
  40.         image_put_pixel(buf->image, loc(x, y),
  41.             pixel_color(loc(x, y + shift), attr, bak), dis.X, dis.Y);
  42.     buf->put_bound(i);
  43.     }
  44.  
  45.  
  46.     }